package com.oa.modules.approvalsec1.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.oa.modules.approvalsec1.entity.IntelligentOfficeEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * 智能办
 *
 * @author jiangwei
 * @email 785297226@qq.com
 * @date 2021-10-18 16:40:48
 */
@Mapper
public interface IntelligentOfficeDao extends BaseMapper<IntelligentOfficeEntity> {


    /**
     * 查询总条数
     *
     * @author jiangwei
     * @email 785297226@qq.com
     * @date 2021-10-18 16:40:48
     * @Description 查询分页数据
     */
    @Select("<script>SELECT COUNT( 1 ) FROM (" +
            "select t1.* from intelligent_office t1  " +
            "where " +
            "<if test = 'params != null '> "+
            "t1.`STATUS` = #{params.status} " +
            ") </if> TOTAL</script>")
    long findPage(@Param("params") Map<String, Object> params);

    /**
     * 查询分页数据
     *
     * @author jiangwei
     * @email 785297226@qq.com
     * @date 2021-10-18 16:40:48
     * @Description 查询分页数据
     */
    @Select("<script>select t1.* from intelligent_office t1 " +
            "where " +
            "t1.`STATUS` = #{params.status} " +
            "ORDER BY t1.CREATE_DATE desc</script>")
    List<IntelligentOfficeEntity> findRecords(IPage<IntelligentOfficeEntity> page, @Param("params") Map<String, Object> params);

}
